<template>
  <view id="headerBar">
    <view class="header-left">
      <view class="Stash flex">
        <view @tap="showDrawer('showStash')" class="logo flex">
          <view class="more flex">
            <text></text> <text></text> <text></text>
          </view>
          <view class="icon">
            <image
              class="medium_Icon"
              :src="baseURL + '/' + userStore.defaultStash.GodownImg" />
          </view>
        </view>
        <view class="msg flex">
          <text class="name fs_16">
            {{ userStore.defaultStash.GodownName }}
          </text>
          <text class="admin fs_12">
            {{ userStore.profile.StaffName }}
          </text>
        </view>
        <!--仓库 Drawer -->
        <uni-drawer
          ref="showStash"
          mode="left"
          :width="870"
          @change="change($event, 'showStash')">
          <!-- Drawer内容 -->
          <zk-homeDraw></zk-homeDraw>
        </uni-drawer>
      </view>
    </view>
    <view class="header-right flex">
      <view @tap="showDrawer('showSelect')" class="search small_Icon flex">
        <image class="small_Icon" src="@/static/img/home/search.png" />
      </view>
      <view @tap="showDrawer('showMessage')" class="message small_Icon flex">
        <!-- <text class="tag"></text> -->
        <image class="small_Icon" src="@/static/img/home/info.png" />
      </view>
    </view>
    <!--搜索 Drawer -->
    <uni-drawer ref="showSelect" mode="right" :width="720">
      <!-- Drawer内容 -->
      <zk-searchDraw @back="closeDrawer"></zk-searchDraw>
    </uni-drawer>
    <!--预警消息 Drawer -->
    <uni-drawer ref="showMessage" mode="right" :width="700">
      <!-- Drawer内容 -->
      <zk-msgDetail @back="closeDrawer"></zk-msgDetail>
    </uni-drawer>
  </view>
</template>

<script lang="ts" setup>
import { useMemberStore } from "@/stores/modules/member"; //用户信息
import { useMessageStore } from "@/stores/modules/message"; //消息
import { baseURL } from "@/utils/api/http";
const msgStore = useMessageStore();
const userStore = useMemberStore();
const showStash: any = ref(null);
const showSelect: any = ref(null);
const showMessage: any = ref(null);
const showDrawer = (str: string) => {
  switch (str) {
    case "showStash":
      userStore.getStashlist();
      showStash.value.open();
      break;
    case "showSelect":
      showSelect.value.open();
      break;
    case "showMessage":
      showMessage.value.open();
      msgStore.showType = "list";
      break;
  }
};

const openDrawer = () => {
  showDrawer("showStash");
};
defineExpose({
  openDrawer,
});
const change = () => {};
const back = () => {
  closeDrawer();
};
const closeDrawer = () => {
  showStash.value.close();
  showSelect.value.close();
  showMessage.value.close();
};
</script>

<style lang="scss" scoped>
#headerBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  //抽屉样式
  ::v-deep .uni-drawer__content {
    border-radius: 10px;
  }
  .header-left {
    .Stash {
      .logo {
        .more {
          height: 20px;
          flex-direction: column;
          justify-content: space-between;
          text {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background-color: #000;
          }
        }
        .icon {
          width: 36px;
          height: 36px;
          border-radius: 50%;
          background-color: #32966f;
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          align-items: center;
          margin: 0 4px;
          image {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }
      }
      .msg {
        flex-direction: column;
        .admin {
          color: rgb(141, 143, 155);
        }
      }
    }
  }
  .header-right {
    .message {
      margin: 0 5px 0 20px;
      position: relative;
      .tag {
        position: absolute;
        top: 0;
        right: 0;
        width: 5px;
        height: 5px;
        background-color: #ff0000;
        border-radius: 50%;
      }
    }
  }
}
</style>
